﻿using System.Collections.Generic;
using Gp.Scripts.Core;
using Gp.Scripts.Data.Skills;
using Gp.Scripts.Equip;

namespace Gp.Scripts.Core {
    
    /// <summary>
    /// 攻击前触发的反应
    /// </summary>
    public class AttackPreReaction : ReactionArgs {
        // 攻击是否可被格挡
        public readonly bool Stoppable;
        public readonly bool IsCharging;
        public readonly BaseUnit Attacker;
        public readonly BaseUnit Target;

        public float DefencePercent;

        public bool BlockedAttack => DefencePercent > 0;
        public List<SkillTags> Tags;
        
        

        /// <summary>
        ///  使用的武器
        /// </summary>
        public readonly WeaponEntity WeaponEntity;

        public bool MeleeCounterAttack;


        public AttackPreReaction(BaseUnit attacker, BaseUnit target, bool stoppable, bool isCharging,
            WeaponEntity weaponEntity) {
            Attacker = attacker;
            Target = target;
            // JudgeStat = judgeStat;
            WeaponEntity = weaponEntity;
            Tags = WeaponEntity.SkillTag();
            IsCharging = isCharging;

            Stoppable = stoppable;
        }
        
        
        public AttackPreReaction(BaseUnit attacker, BaseUnit target, WeaponEntity weaponEntity) {
            Attacker = attacker;
            Target = target;
            WeaponEntity = weaponEntity;
            Tags = WeaponEntity.SkillTag();
            IsCharging = false;

            Stoppable = true;
        }

        public bool IsMeleeAttack() {
            return WeaponEntity.TypeCode.IsMeleeWeapon();
        }
        
    }
}